package easy;

public class Solution_836 {

    public boolean isRectangleOverlap(int[] rec1, int[] rec2) {
        long[] int_x = {Math.abs(rec1[0] - rec1[2]), Math.abs(rec1[0] - rec2[0]), Math.abs(rec1[0] - rec2[2]), Math.abs(rec1[2] - rec2[0]), Math.abs(rec1[2] - rec2[2]), Math.abs(rec2[0] - rec2[2])};
        long[] int_y = {Math.abs(rec1[1] - rec1[3]), Math.abs(rec1[1] - rec2[1]), Math.abs(rec1[1] - rec2[3]), Math.abs(rec1[3] - rec2[1]), Math.abs(rec1[3] - rec2[3]), Math.abs(rec2[1] - rec2[1])};
        long maxWidth = 0, maxHeight = 0;
        for (long intX : int_x) {
            maxWidth = Math.max(maxWidth, intX);
        }
        for (long intY : int_y) {
            maxHeight = Math.max(maxHeight, intY);
        }
        long width = 0l + Math.abs(rec1[2] - rec1[0]) + Math.abs(rec2[2] - rec2[0]);
        long height = 0l +Math.abs(rec1[3] - rec1[1]) + Math.abs(rec2[3] - rec2[1]);
        return maxWidth < width && maxHeight < height;
    }

    public static void main(String[] args) {
        Solution_836 model = new Solution_836();
//        System.out.println(model.isRectangleOverlap(new int[]{0, 0, 2, 2}, new int[]{1, 1, 3, 3}));
//        System.out.println(model.isRectangleOverlap(new int[]{0, 0, 1, 1}, new int[]{1, 0, 2, 1}));
        System.out.println(model.isRectangleOverlap(new int[]{4, 0, 6, 6}, new int[]{-5, -3, 4, 2}));
        System.out.println(model.isRectangleOverlap(new int[]{-257926405,-680763313,702840196,454409669}, new int[]{-275916328,-417802221,22808107,675629469}));
        System.out.println(Long.MAX_VALUE);
    }
}
